
<template>
	<div>
		<basic-container>
			<el-row> <el-col :span="6"></el-col>
			<el-col :span="12">
				<el-progress :text-inside="true" :stroke-width="26" :percentage="data.five==0?0:(data.five/data.count).toFixed(2)*100" status="success"></el-progress>
				<el-progress :text-inside="true" :stroke-width="24" :percentage="(data.count-data.five)==0?0:((data.count-data.five)/data.count).toFixed(2)*100" status="exception" style="margin-top: 10px;"></el-progress>
				<p>{{$t('wel.table.taskId')}}：{{data.taskId}}</p>
				<p>{{$t('wel.table.create_time')}}：{{data.create_time}}</p>
				<p>{{$t('wel.table.taskcount')}}：{{data.count}}</p>
				<p>{{$t('wel.table.taskError')}}：{{data.three}}</p>
				<p>{{$t('wel.table.tasksuccess')}}：{{data.five}}</p>
				<p>{{$t('wel.table.Unsent_device')}}：{{data.one}}</p>
				<p>{{$t('wel.table.Equipment_responded')}}：{{data.two}}</p>
				
				</el-col>
			</el-row>
			<avue-crud :option="option4" :data="data.list.data" :page.sync="page" @size-change="sizeChange"
				@current-change="currentChange" @search-change="searchChange">
			</avue-crud>
		</basic-container>
	</div>
</template>

<script>
	import {
		mapGetters
	} from "vuex";
	import request from '@/router/axios';
	import {
		baseUrl
	} from '@/config/env';

	export default {
		props: {
			id: {
				type: Number,
				default: 0
			}
		},
		name: "wel",
		data() {
			return {
				detail: {},
				data: {},
				type: '',
				box: false,
				isDetail: false,
				page: {
					currentPage: 1,
					total: 0,
					layout: "total,pager,prev, next",
					background: false,
					pageSize: 10
				},
				delval: null,
			};
		},
		computed: {
			...mapGetters(["userInfo"]),
			option4() {
				return {
					//index: true,
					menuType: "icon",
					align: 'center',
					addBtn: false,
					editBtn: false,
					delBtn:false,
					menuAlign: 'center',
					column: [{
							label: this.$t("wel.table.code"),
							prop: "code",

						},
						{
							label: this.$t("wel.table.tastStatus"),
							prop: "status",
						}

					]
				};
			}
		},
		created() {
			this.getList({
				'page': 1,
				'pageSize': this.page.pageSize
			})

		},
		methods: {
			searchChange(params, done) {
				if (!params) {
					this.$message.err("请输入搜索内容");
				}
				done();
				this.getList({
					'id': params['id'],
					'name': params['name'],
					'code': params['code'],
					'pageSize': 10,
					'page': 1
				});
			},
			sizeChange(val) {
				this.page.currentPage = 1
				this.page.pageSize = val
				this.getList()
			},

			currentChange(val) {
				this.page.currentPage = val
				this.getList({
					'page': val,
					'pageSize': this.page.pageSize
				});
			},

			getList(data) {
				data.id=this.id
				let that = this;
				
				request({
						headers: {
							'Content-Type': 'application/json;charset=utf-8'
						},
						method: 'post',
						url: baseUrl + 'userapi/task/getTaskDetail',
						data: data
					})
					.then(function(response) {
						if (response.data.status == 0) {
							that.$message.error(response.data.info)
						} else if (response.data.status == 1) {
							that.data = response.data.data;
							console.log(that.data);
							that.data.list.data.forEach(function(item,index){
								if(item.status==1){
									that.data.list.data[index].status=that.$t("wel.table.operation_failed");
								}
								else if(item.status==2){
									that.data.list.data[index].status=that.$t("wel.table.operation_failed");
								}
								else if(item.status==3){
									that.data.list.data[index].status=that.$t("wel.table.operation_failed");
								}
								 else if(item.status==4){
								 	that.data.list.data[index].status=that.$t("wel.table.Operation_succeeded");
								 }
							 })
							that.page.total =that.data.list.total;
							that.page.pageSize = that.data.list.per_page;
						}
					})
					.catch(function(error) {
						that.$message.error('系统错误')
					});

			}
		}
	};
</script>

<style scoped="scoped" lang="scss">
	.wel {
		&__header {
			padding: 25px 40px;
			border-bottom: 1px solid #e8e8e8;
			background-color: #fff;
			display: flex;
			justify-content: space-between;
			align-items: center;
		}

		&__info {
			display: flex;
			align-items: center;

			&-img {
				border-radius: 72px;
				display: block;
				width: 72px;
				height: 72px;

				img {
					width: 100%;
					height: 100%;
					display: block;
				}
			}

			&-content {
				position: relative;
				margin-left: 24px;
				color: rgba(0, 0, 0, 0.45);
				line-height: 22px;
			}

			&-title {
				font-size: 20px;
				line-height: 28px;
				font-weight: 500;
				color: rgba(0, 0, 0, 0.85);
				margin-bottom: 12px;
			}

			&-subtitle {
				position: relative;
				font-size: 14px;
				color: rgba(0, 0, 0, 0.45);
				line-height: 22px;
			}
		}

		&__extra {
			&-item {
				position: relative;
				padding: 0 32px;
				display: inline-block;

				&:last-child {
					&::after {
						display: none;
					}
				}

				&:after {
					background-color: #e8e8e8;
					position: absolute;
					top: 30px;
					right: 0;
					width: 1px;
					height: 40px;
					content: "";
				}
			}

			&-title {
				color: rgba(0, 0, 0, 0.45);
				font-size: 14px;
				line-height: 22px;
				margin-bottom: 4px;
			}

			&-subtitle {
				color: rgba(0, 0, 0, 0.85);
				font-size: 30px;
				line-height: 38px;
				margin: 0;

				span {
					color: rgba(0, 0, 0, 0.45);
					font-size: 20px;
				}
			}
		}
	}
</style>
